# Importing Data
CHINA<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "b1:b325")

# Checking the Imported Data
View(CHINA)
# Creating Time Series Data
CHINA_ts <- ts(CHINA, start=c(1991,1), end=c(2017,12), frequency=12)
# Viewing and Checking the Created Time Series Data
CHINA_ts
sum(is.na(CHINA_ts))
library(forecast)
CHINA_ts <- tsclean(CHINA_ts)
CHINA_ts

# Identification: Plotting the Time Series Data
plot(CHINA_ts)

# Estimating the appropriate model
CHINA_ts_model <- auto.arima(CHINA_ts)
CHINA_ts_model

# Forecasting
options(max.print=1000000)
CHINA_ts_forecast <- forecast (CHINA_ts_model, level=c(95), h=276)
plot(CHINA_ts_forecast)
CHINA_ts_forecast             

# Exporting
write.table(CHINA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/CHINA_TSA.csv", sep=",")


